##
##    This file is part of Metrix.
##
##    Metrix is free software: you can redistribute it and/or modify
##    it under the terms of the GNU General Public License as published by
##    the Free Software Foundation, either version 3 of the License, or
##    (at your option) any later version.
##
##    Metrix is distributed in the hope that it will be useful,
##    but WITHOUT ANY WARRANTY; without even the implied warranty of
##    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
##    GNU General Public License for more details.
##
##    You should have received a copy of the GNU General Public License
##    along with Metrix.  If not, see <http://www.gnu.org/licenses/>.
##

class Recurso < ActiveRecord::Base
	has_many :incidentes_creados, :foreign_key => "creador_id",  :class_name => "Incidente", 
#		:dependent => :nullify
		:dependent => :protect

	has_many :incidentes_asignados, :foreign_key => "asignado_id", :class_name => "Incidente", 
#		:dependent => :nullify
		:dependent => :protect
	
	validates_uniqueness_of :nombre, :scope => :apellido, :message => "ya existente"

	validates_presence_of :nombre, :message => "es un campo obligatorio."
	validates_presence_of :apellido, :message => "es un campo obligatorio."
	validates_inclusion_of :tipo, :in => %w{ Desarrollador Analista Diseñador Tester Otro }
	validates_inclusion_of :seniority, :in => %w{ Trainee Junior SemiSenior Senior }

  def nombreCompleto
    self.nombre + " " + self.apellido
  end

  def to_s
    nombreCompleto
  end

end
